package com.huawei.appgallery.wishlist.ui.cardkit.card;

import android.content.Context;
import android.text.SpannableString;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.card.base.normal.bean.NormalCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appmarket.framework.widget.NoAdaptRenderImageView;
import huawei.widget.HwTextView;
import o.azb;
import o.cgz;
import o.dce.d;
import o.dce.e;
import o.dni;
import o.dof;
import o.epv;
import o.eqx;

public class WishNormalCard extends BaseDistCard {
    private View ʻ;
    protected TextView ʼ;
    protected int ʽ;
    private NoAdaptRenderImageView ˊॱ;
    protected TextView ˋ;
    private RelativeLayout ˏॱ;
    private ImageView ͺ;
    private TextView ॱˊ;
    private HwTextView ॱॱ;
    private ImageView ᐝ;

    public WishNormalCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ˏ((ImageView) view.findViewById(e.ᐝ));
        ˎ((ImageView) view.findViewById(e.ʽ));
        ॱ((TextView) view.findViewById(e.ˎ));
        ˊ((TextView) view.findViewById(e.ˋ));
        ˋ((DownloadButton) view.findViewById(e.ʻॱ));
        this.ॱˊ = (TextView) view.findViewById(e.ˉ);
        this.ˋ = (TextView) view.findViewById(e.ˊˋ);
        this.ᐝ = (ImageView) view.findViewById(e.ʽॱ);
        this.ͺ = (ImageView) view.findViewById(e.ˈ);
        this.ॱॱ = (HwTextView) view.findViewById(e.ˏ);
        this.ʻ = view.findViewById(e.ˏॱ);
        azb.ʻ(this.ʻ);
        this.ʼ = (TextView) view.findViewById(e.ˊ);
        this.ˊॱ = (NoAdaptRenderImageView) view.findViewById(e.ˊᐝ);
        this.ˏॱ = (RelativeLayout) view.findViewById(e.ˋˋ);
        azb.ʻ(this.ˏॱ);
        ʽ(view);
        return this;
    }

    public void ˋ(int i) {
        this.ʽ = i;
    }

    public void w_() {
        eqx.ˏ(this.ʽॱ, this.ˊᐝ.ॱˌ(), "app_default_icon");
    }

    protected int ˊ() {
        return azb.ˊ(this.ˊˋ.getContext());
    }

    protected int ˎ() {
        return azb.ˏ(this.ˊˋ.getContext());
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        NormalCardBean normalCardBean = (NormalCardBean) cardBean;
        if (ˊᐝ()) {
            this.ʻ.setVisibility(0);
        } else {
            this.ʻ.setVisibility(4);
        }
        LayoutParams layoutParams = (LayoutParams) ʼॱ().getLayoutParams();
        if (dof.ʽ(normalCardBean.ʽॱ())) {
            this.ॱॱ.setVisibility(8);
            layoutParams.setMarginEnd(this.ʼॱ.getResources().getDimensionPixelSize(d.ˏ));
        } else {
            layoutParams.setMarginEnd(this.ʼॱ.getResources().getDimensionPixelSize(d.ॱ));
            this.ॱॱ.setVisibility(0);
            this.ॱॱ.setText(ˊ(normalCardBean.ʽॱ()));
        }
        layoutParams.setMarginStart(ˊ());
        ((LayoutParams) this.ˏॱ.getLayoutParams()).setMarginEnd(ˎ());
        if (normalCardBean.ˋˋ() != null) {
            int ˋ = (((this.ʽ - ((LayoutParams) ʽ().getLayoutParams()).width) - epv.ˋ(ʼॱ().getContext(), 16)) - ˎ()) - ((layoutParams.width + layoutParams.getMarginStart()) + epv.ˋ(ʼॱ().getContext(), 16));
            if (normalCardBean.ˋˋ().ˊ() != null) {
                ˋ -= epv.ˋ(ʼॱ().getContext(), 19);
            }
            if (normalCardBean.ˋˋ().ॱ() != null) {
                ˋ -= epv.ˋ(ʼॱ().getContext(), 19);
            }
            ˊˋ().setMaxWidth(ˋ);
            ˊ(this.ᐝ, normalCardBean.ˋˋ().ˊ());
            ˊ(this.ͺ, normalCardBean.ˋˋ().ॱ());
        }
        ˊ(normalCardBean);
        ˋ(this.ॱˊ, normalCardBean.ˋʻ());
    }

    public boolean ˋ(TextView textView, String str) {
        textView.setVisibility(dof.ॱ(str) ? 8 : 0);
        if (dof.ॱ(str)) {
            return false;
        }
        textView.setText(str);
        return true;
    }

    private String ˊ(String str) {
        if (str.contains(".")) {
            return str.substring(0, str.indexOf("."));
        }
        return str;
    }

    private boolean ˊ(ImageView imageView, String str) {
        if (imageView == null) {
            return false;
        }
        if (dni.ˏ(str)) {
            imageView.setVisibility(8);
            return false;
        }
        imageView.setVisibility(0);
        return true;
    }

    public void x_() {
        NormalCardBean normalCardBean = (NormalCardBean) this.ˊᐝ;
        CharSequence ˏ = ˏ((BaseCardBean) normalCardBean);
        if (normalCardBean.ͺ() == 1 || normalCardBean.ͺ() == 3) {
            if (this.ˉ != null) {
                this.ˉ.setText(normalCardBean.ॱˎ());
            }
            this.ʼ.setVisibility(8);
        } else if (this.ˉ == null || this.ʼ == null || dof.ʽ(normalCardBean.ˊ()) || dof.ʽ(normalCardBean.an_()) || ˏ != null) {
            if (this.ˉ != null) {
                if (ˏ != null) {
                    this.ˉ.setText(ˏ);
                } else {
                    this.ˉ.setText(normalCardBean.ˏˏ());
                }
            }
            if (this.ʼ != null) {
                this.ʼ.setVisibility(8);
            }
        } else {
            this.ˉ.setText(normalCardBean.an_());
            this.ʼ.setVisibility(0);
            this.ʼ.setText(normalCardBean.ˊ());
        }
    }

    protected void ˊ(NormalCardBean normalCardBean) {
        if (normalCardBean.ٴ() != 0) {
            String ՙ = normalCardBean.ՙ();
            if (dof.ˋ(ՙ)) {
                this.ˊॱ.setVisibility(8);
            } else {
                this.ˊॱ.setVisibility(0);
                eqx.ˏ(this.ˊॱ, ՙ, "iconflag");
            }
            CharSequence ߴ = normalCardBean.ߴ();
            if (dof.ˋ(ߴ)) {
                this.ˋ.setVisibility(4);
                return;
            }
            this.ˋ.setText(ߴ);
            this.ˋ.setVisibility(0);
            return;
        }
        this.ˊॱ.setVisibility(8);
        if (dof.ʽ(normalCardBean.ˎͺ())) {
            this.ˋ.setVisibility(4);
            return;
        }
        this.ˋ.setText(normalCardBean.ˎͺ());
        this.ˋ.setVisibility(0);
    }

    public SpannableString ˎ(BaseDistCardBean baseDistCardBean, SpannableString spannableString) {
        if (baseDistCardBean == null || baseDistCardBean.ˏˏ() == null) {
            return null;
        }
        return SpannableString.valueOf(baseDistCardBean.ˏˏ());
    }
}
